home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / alexrk / alexhelp.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  5.6 KB  |  171 lines

  1. VERSION 2.00
  2. Begin Form Form2 
  3.    Caption         =   "Alex's Rocket Programmer Help"
  4.    ClientHeight    =   4260
  5.    ClientLeft      =   225
  6.    ClientTop       =   2625
  7.    ClientWidth     =   9240
  8.    Height          =   4665
  9.    Left            =   165
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form2"
  12.    ScaleHeight     =   4260
  13.    ScaleWidth      =   9240
  14.    Top             =   2280
  15.    Width           =   9360
  16.    Begin TextBox HelpText 
  17.       Height          =   3345
  18.       Left            =   3045
  19.       MultiLine       =   -1  'True
  20.       ScrollBars      =   2  'Vertical
  21.       TabIndex        =   1
  22.       Text            =   "HelpText"
  23.       Top             =   600
  24.       Width           =   6120
  25.    End
  26.    Begin ListBox HelpIndex 
  27.       Height          =   3150
  28.       Left            =   30
  29.       TabIndex        =   0
  30.       Top             =   600
  31.       Width           =   3030
  32.    End
  33.    Begin CommandButton Command2 
  34.       Caption         =   "Find Next"
  35.       Height          =   360
  36.       Left            =   4665
  37.       TabIndex        =   3
  38.       Top             =   135
  39.       Width           =   1260
  40.    End
  41.    Begin CommandButton Command1 
  42.       Caption         =   "Exit Help"
  43.       Height          =   360
  44.       Left            =   3225
  45.       TabIndex        =   2
  46.       Top             =   135
  47.       Width           =   1260
  48.    End
  49.    Begin Label Label1 
  50.       Caption         =   "Click Topic Below - Text will Appear in window at right"
  51.       Height          =   480
  52.       Left            =   120
  53.       TabIndex        =   4
  54.       Top             =   75
  55.       Width           =   2955
  56.    End
  57. Dim HelpData As String
  58. Dim IndexEntry As String
  59. Dim NL As String
  60. Dim StartSearch As Long
  61. Sub CheckForContextLookup ()
  62.     ' Help Topic can be loaded with a value to simulate
  63.     '  context sensitive help
  64.     If Len(HelpTopic$) > 0 Then
  65.         StartSearch = 1
  66.         LookupText (HelpTopic$)
  67.     End If
  68. End Sub
  69. Sub Command1_Click ()
  70.     Unload Form2
  71. End Sub
  72. Sub Command2_Click ()
  73.     ' Find Next Control
  74.     ' Execute same routine as normal lookup only don't reset
  75.     ' starting point to top of text area
  76.     StartSearch& = HelpText.selstart + 3
  77.     ' return to top when end of file reached
  78.     If StartSearch > Len(HelpText.Text) Then StartSearch = 1
  79.     'FindString'
  80.     HelpText.selstart = Len(HelpText.Text)
  81.     LookupText (HelpTopic)
  82. End Sub
  83. Sub Form_GotFocus ()
  84. Screen.MousePointer = 1
  85. End Sub
  86. Sub Form_Load ()
  87.     Screen.MousePointer = 11
  88.     StartSearch = 1
  89.     LoadHelpIndex
  90.     LoadHelpText
  91.     CheckForContextLookup
  92. End Sub
  93. Sub HelpIndex_Click ()
  94.     HelpTopic = LTrim$(RTrim$(HelpIndex.Text))
  95.     LookupText (HelpTopic$)
  96. End Sub
  97. Sub HelpIndex_GotFocus ()
  98. Screen.MousePointer = 1
  99. End Sub
  100. Sub HelpText_GotFocus ()
  101.     Screen.MousePointer = 1
  102. End Sub
  103. Sub LoadHelpIndex ()
  104. LoadIndexAgain:
  105. On Error GoTo IndexError
  106. ' ** Help File data and index paths are stored in the first
  107. ' ** lines of the ALEX.BAS file
  108. ' ** Their default locations are C:\VB directory
  109. ' ** If they are not found there you will be prompted below to
  110. ' ** supply the correct path.
  111. FN% = FreeFile
  112. If NewHelpPath <> "" Then
  113.     HelpIndexPath$ = RTrim$(LTrim$(NewHelpPath$)) + "\" + HelpIndexFile$
  114.     HelpIndexPath$ = HelpPath$ + "\" + HelpIndexFile$
  115. End If
  116. Open HelpIndexPath$ For Input As FN%
  117. Do While Not EOF(FN%)
  118.     Line Input #FN%, IndexEntry$
  119.     HelpIndex.AddItem (IndexEntry$)
  120. Close #FN%
  121. Exit Sub
  122. IndexError:
  123.     NewHelpPath$ = RTrim$(InputBox$("Error Finding Help Files. Enter Drive and Directory where they are loaded. Default (assigned in .BAS file) is C:\VB.  Enter:", "Help Index Path", HelpPath))
  124.     If NewHelpPath$ = "" Then Exit Sub
  125.     ' Resume program execution with statement causing error
  126.     Resume LoadIndexAgain
  127. End Sub
  128. Sub LoadHelpText ()
  129. LoadTextAgain:
  130. On Error GoTo TextError
  131. ' ** Help File data and index paths are stored in the first
  132. ' ** lines of the ALEX.BAS file
  133. ' ** Their default locations are C:\VB directory
  134. ' ** If they are not found there you will be prompted below to
  135. ' ** supply the correct path.
  136. NL$ = Chr$(13) + Chr$(10)
  137. FNT% = FreeFile
  138. If NewHelpPath$ <> "" Then
  139.     HelpTextPath$ = NewHelpPath$ + "\" + HelpTextFile$
  140.     HelpTextPath$ = HelpPath$ + "\" + HelpTextFile$
  141. End If
  142. Open HelpTextPath$ For Input As FNT%
  143. Do While Not EOF(FNT%)
  144.     Line Input #FNT%, HelpData$
  145.     HelpTextLine$ = HelpTextLine$ + HelpData$ + NL$
  146.     Loop
  147. HelpText.Text = HelpTextLine$
  148. Close #FNT%
  149. Exit Sub
  150. TextError:
  151.     NewHelpPath = RTrim$(InputBox$("Error Finding Help Files. Enter Drive and Directory where they are loaded. Default (assigned in .BAS file) is C:\VB.  Enter:", "Help Text Path", HelpPath))
  152.     If NewHelpPath$ = "" Then Exit Sub
  153.     ' Resume program execution at satement causing error
  154.     Resume LoadTextAgain
  155. End Sub
  156. Sub LookupText (HelpTopic As String)
  157.     HelpText.selstart = Len(HelpText.Text)
  158. 'InStr returns location of text using the HelpTopic as lookup
  159. ' CSng convert this value for use in positioning
  160. ' within text box
  161.     If InStr(StartSearch, HelpText.Text, HelpTopic) > 1 Then
  162.         HelpText.selstart = InStr(StartSearch, HelpText.Text, HelpTopic) - 1
  163.         HelpText.sellength = CSng(Len(HelpTopic))
  164.     End If
  165.     ' return to top when end of file reached
  166.     If StartSearch > Len(HelpText.Text) Then StartSearch = 1
  167.     ' Clear value of HelpTopic after each search unless
  168.     ' FindNext drives the search
  169.     ' HelpTopic = ""
  170. End Sub
  171.